package com.adee.java;

public class Test032_innerClass {
    public static void main(String[] args) {
        Parent.Son son = new Parent().new Son("Jack");
        son.speak();
    }
}

class Animal {
    static String category;
    // 静态内部类，作为命名空间用，成员变量之间无联系
    static class Dog {
        String name;
        String color;
        public void run(){
            System.out.println(category + ":" + name + " run");
        }
    }
}

class Parent {
    String name;
    // 实例内部类，必须先创建父类对象，才能创建内部类对象
    public class Son {
        public Son(String name) {
            Parent.this.name = name;
        }
        public void speak() {
            System.out.println("my parents name is " + name);  // 此处的name相当于 Parent.this.name
        }
    }
}
